package com.ydd.mapper;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.ydd.entity.YddAdvpos;
import lombok.Builder;
import org.apache.ibatis.annotations.*;

import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
@TableName("ydd_advpos")
public interface YddAdvposMapper extends BaseMapper<YddAdvpos> {
    /**
     * 广告位分页
     * @param advposdesc
     * @param advposname
     * @return
     */
    Page<YddAdvpos> list(String advposdesc, String advposname);

    /**
     * 广告位详情
     * @param id
     * @return
     */
    @Select("select * from ydd_advpos where id=#{id}")
    YddAdvpos getById(Integer id);

    /**
     * 广告位添加
     * @param advposname
     * @param advposdesc
     * @param advpossize
     */
    @Insert("INSERT INTO ydd_advpos VALUES (null, #{advposname}, #{advposdesc},#{advpossize},1)")
    void add(String advposname, String advposdesc, String advpossize);

    /**
     * 广告位-全部
     * @return
     */
    @Select("select  * from ydd_advpos")
    List<YddAdvpos> all();

    /**
     * 广告位修改
     * @param id
     * @param advposname
     * @param advposdesc
     * @param advpossize
     */
    @Update("UPDATE ydd_advpos SET advposname=#{advposname},advposdesc=#{advposdesc},advpossize=#{advpossize} WHERE id=#{id};")
    void update(Integer id, String advposname, String advposdesc, String advpossize);

    /**
     * 广告位删除
     * @param id
     */
    @Delete("DELETE FROM ydd_advpos WHERE id=#{id}")
    void delete(Integer id);
    /**
     * 获取所有广告位数
     * @return
     */
    @Select("select count(*) from ydd_advpos")
    Integer count();
}
